﻿using System;
using UnityEngine;

public abstract class CommandLogicSOBase : ScriptableObject
{
    Action doneCB;
    object param;
    public void Execute(Action doneCB, float delay = -1, object param = null)
    {
       
        if (delay >0)
        {
            this.doneCB = doneCB;
            this.param = param;
            this.Log("开始计时"+ delay);
            GameRoot.Instance.timerService.AddTimer((int)(delay * 1000), OnExecuteDelay);
            return;
        }
        this.doneCB = null;
        this.param = null;
        OnExecute(doneCB, param);
    }

    private void OnExecuteDelay()
    {
        this.Log("执行");
        OnExecute(doneCB, param);
    }

    protected abstract void OnExecute(Action doneCB,object param =null);
   
}